package com.cool.collect.springcode.a06;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xiemiao
 * @description
 * @date 2023/08/31
 */
@Configuration
public class MyConfig2 implements InitializingBean, ApplicationContextAware {
    private static final Logger log = LoggerFactory.getLogger(MyConfig2.class);

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        log.info("注入ApplicationContext");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        log.info("初始化");
    }

    @Bean //beanFactory后处理器
    public BeanFactoryPostProcessor processor2() {
        return beanFactory -> {
            log.info("执行processor2");
        };
    }

}
